home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_487 / pprint / source / pprint.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  32KB  |  1,145 lines

  1. /************************************************************************
  2. *                                                                                                *
  3. *        PPrint                                                                                *
  4. *                                                                                                *
  5. *-----------------------------------------------------------------------*
  6. *                                                                                                *
  7. *        Endlich ein vernünftiges Utility, für den User, der einfach nur    *
  8. *        seine Texte vernünftig ausdrucken will.                                    *
  9. *                                                                                                *
  10. *-----------------------------------------------------------------------*
  11. *                                                                                                *
  12. *        V 1.10    ©1991 by Marc Jackisch                                                *
  13. *                                                                                                *
  14. ************************************************************************/
  15.  
  16. #include <exec/types.h>
  17. #include <exec/memory.h>
  18. #include <intuition/intuition.h>
  19. #include <libraries/dos.h>
  20. #include <libraries/dosextens.h>
  21. #include <libraries/reqbase.h>
  22. #include <devices/printer.h>
  23. #include <private/help.h>
  24. #include <private/deva.h>
  25.  
  26. #include <proto/exec.h>
  27. #include <proto/dos.h>
  28. #include <proto/intuition.h>
  29. #include <proto/graphics.h>
  30. #include <proto/reqproto.h>
  31.  
  32. #include    "settings.h"
  33. #include "PPrintX.h"
  34.  
  35. /***************************************
  36.  
  37.                     Definitions
  38.  
  39. ***************************************/
  40.  
  41. #define    RP            ( FirstWindow->RPort )
  42. #define    PRTLEN    sizeof( struct IODRPReq )
  43.  
  44. /***************************************
  45.  
  46.                         Globals
  47.  
  48. ***************************************/
  49.  
  50. LONG __far        _stack = 4000;
  51. char __far      *_procname = "PPrint-procedure";
  52. LONG __far         _priority = 0;
  53. LONG __far         _BackGroundIO = 0;
  54.  
  55. struct IntuitionBase          *IntuitionBase;
  56. struct GfxBase                  *GfxBase;
  57. struct ReqBase                  *ReqBase;
  58. struct IODRPReq              *GPrtReq;
  59. struct IOStdReq              *PrtReq;
  60. struct IOPrtCmdReq          *CmdReq;
  61. struct Window                  *FirstWindow;
  62. struct Screen                  *FirstScreen;
  63. struct Process                  *MyProcess;
  64. APTR                                window_save        =    NULL;
  65. BOOL                                gRun;
  66.  
  67. LONG                                Memsize            =    0L;
  68. UBYTE                              *ActFile            =    NULL;
  69.  
  70. struct Settings                Sets[ 10 ];
  71. SHORT                                ActSet            =    1;
  72.  
  73. SHORT                                CurLay            =    1;        /* Current Layout */
  74. USHORT                            OTSize;
  75. SHORT                                Topline            =    0;
  76. UBYTE                                LineBuf[ 128 ];
  77.  
  78. SHORT                                LAYOUT_TOP,
  79.                                     NUM_LINES,
  80.                                     NUMTOP,
  81.                                     SECTOP,
  82.                                     STRINGTOP,
  83.                                     ACTIONTOP,
  84.                                     PT1TOP,
  85.                                     PT2TOP,
  86.                                     SWITCHTOP;
  87.  
  88. UBYTE                              *HashTab[ 5120 ];
  89. SHORT                                NumLines;
  90.  
  91. /***************************************
  92.  
  93.                     Constants
  94.  
  95. ***************************************/
  96.  
  97. UBYTE                                ScTitle[]    =
  98. "PPrint V1.10  File: < none >                                              ";
  99.  
  100. struct NewScreen                FirstNewScreen    =
  101. {
  102.     0,    0,
  103.     640,    STDSCREENHEIGHT,
  104.     3,    0,    1,
  105.     HIRES,
  106.     CUSTOMSCREEN,
  107.     NULL,
  108.     ScTitle,
  109.     NULL,
  110.     NULL
  111. };
  112.  
  113. struct NewWindow                FirstNewWindow =
  114. {
  115.     0, 0,
  116.     640, 0,
  117.     0, 1,
  118.     RAWKEY | GADGETUP | MENUPICK | MOUSEBUTTONS,
  119.     SMART_REFRESH | ACTIVATE | BORDERLESS | BACKDROP,
  120.     NULL,
  121.     NULL,
  122.     NULL,
  123.     NULL,
  124.     NULL,
  125.     0,0,0,0,
  126.     CUSTOMSCREEN
  127. };
  128.  
  129. UBYTE                                LoadString[]        =    "Open a file";
  130. struct FileInfoBlock          *FIB;
  131. UBYTE                                Dir[ DSIZE + 1 ],
  132.                                     File[ FCHARS + 1 ],
  133.                                     Path[ DSIZE + FCHARS + 2 ];
  134. struct FileRequester            FReq    =
  135. {
  136.     0,
  137.     LoadString,
  138.     Dir,
  139.     File,
  140.     Path,
  141.     NULL,
  142.     0,
  143.     24,
  144.     30,
  145.     13,
  146.     FRQCACHINGM | FRQCACHEPURGEM,
  147.     2,1,2,0,0,0,0,1,1,3,3,3,3
  148. };
  149.  
  150. /***************************************
  151.  
  152.                     Declarations
  153.  
  154. ***************************************/
  155.  
  156. VOID            RawkeyA( USHORT, USHORT );
  157. VOID            MenuA( USHORT );
  158. VOID            GadgetA( struct Gadget * );
  159. BOOL            Open_All( VOID );
  160. VOID            Close_All( VOID );
  161. VOID            NewSet( SHORT );
  162. VOID            NewStyle( SHORT );
  163. VOID            NewCond( BOOL );
  164. VOID            NewLetter( BOOL );
  165. VOID            NewLsp( BOOL );
  166. VOID            NewNuming( SHORT );
  167. VOID            Layout1( VOID );
  168. VOID            Layout2( VOID );
  169. VOID            RefreshTSize( VOID );
  170. VOID            RefreshRMarg( VOID );
  171. VOID            RefreshLMarg( VOID );
  172. VOID            RefreshPLength( VOID );
  173. VOID            RefreshPWidth( VOID );
  174. VOID            DoRefresh( VOID );
  175. VOID            DoInits( SHORT );
  176.  
  177. IMPORT    VOID            About( VOID );
  178. IMPORT    VOID            Load( VOID );
  179. IMPORT    VOID            AskTSize( VOID );
  180. IMPORT    VOID            AskRMarg( VOID );
  181. IMPORT    VOID            AskLMarg( VOID );
  182. IMPORT    VOID            AskPLength( VOID );
  183. IMPORT    VOID            AskPWidth( VOID );
  184. IMPORT    VOID            LoadDefSets( VOID );
  185. IMPORT    VOID            SaveSettings( VOID );
  186. IMPORT    VOID            LoadSettings( VOID );
  187.  
  188. IMPORT    VOID            PreInit( VOID );
  189. IMPORT    VOID            PrintPageWise( VOID );
  190. IMPORT    VOID            PrintAll( VOID );
  191.  
  192. IMPORT    VOID            ShowText( SHORT );
  193.  
  194. /************************************************************************
  195. *                                                                                                *
  196. *        main                                                                                    *
  197. *                                                                                                *
  198. *-----------------------------------------------------------------------*
  199. *                                                                                                *
  200. *        No CLI - parameters this time, so we set ourselves to VOID            *
  201. *                                                                                                *
  202. *-----------------------------------------------------------------------*
  203. *                                                                                                *
  204. *        Parameters        :                                                                    *
  205. *            none                                                                                *
  206. *                                                                                                *
  207. *        Returns            :                                                                    *
  208. *            none                                                                                *
  209. *                                                                                                *
  210. ************************************************************************/
  211.  
  212. VOID        main( VOID )
  213. {
  214.     struct BackMsg          *BM;
  215.  
  216.     /***/
  217.  
  218.     gRun    =    Open_All();
  219.  
  220.     while( gRun )
  221.     {
  222.         BM    =    FetchMsg( FirstWindow );
  223.         switch( BM->Class )
  224.         {
  225.             case    RAWKEY    :    RawkeyA( BM->Code, BM->Qual );
  226.                                     break;
  227.             case    MENUPICK    :    MenuA( BM->Code );
  228.                                     break;
  229.             case    GADGETUP    :    GadgetA(( struct Gadget * )BM->Adr );
  230.                                     break;
  231.             default            :    break;
  232.         }
  233.     }
  234.     if( ActFile )
  235.         free( ActFile );
  236.  
  237.     PurgeFiles( &FReq );
  238.     Close_All();
  239. }
  240.  
  241. /************************************************************************
  242. *                                                                                                *
  243. *        RawkeyA                                                                                *
  244. *                                                                                                *
  245. *-----------------------------------------------------------------------*
  246. *                                                                                                *
  247. *        Deals with Rawkey - messges.                                                    *
  248. *                                                                                                *
  249. *-----------------------------------------------------------------------*
  250. *                                                                                                *
  251. *        Parameters        :                                                                    *
  252. *            cd                :    RAWKEY - code                                                *
  253. *            qu                :    Qualifier                                                    *
  254. *                                                                                                *
  255. ************************************************************************/
  256.  
  257. VOID        RawkeyA( USHORT cd, USHORT qu )
  258. {
  259.     qu    &=    ~( IEQUALIFIER_RELATIVEMOUSE | IEQUALIFIER_REPEAT );
  260.  
  261.     /***************************************
  262.                     Copy of the menus
  263.     ***************************************/
  264.  
  265.     if( qu == IEQUALIFIER_LCOMMAND )
  266.     {
  267.         switch( cd )
  268.         {
  269.             case    0x20    :    About();                            /*    About */
  270.                                 break;
  271.             case    0x18    :    Load();                            /*    Load    */
  272.                                 break;
  273.             case    0x19    :    PrintPageWise();                /*    Print    */
  274.                                 break;
  275.             case    0x10    :    if( TwoGadRequest( "Do you really\nwant to quit ?" ))
  276.                                     gRun    =    FALSE;            /*    Quit    */
  277.                                 break;
  278.             case    0x28    :    LoadSettings();                /*    Load Sets    */
  279.                                 break;
  280.             case    0x21    :    SaveSettings();                /*    Save Sets    */
  281.                                 break;
  282.             case    0x13    :    AskRMarg();                        /* Right Margin */
  283.                                 break;
  284.             case    0x37    :    AskLMarg();                        /* Left Margin */
  285.                                 break;
  286.             case    0x14    :    AskTSize();                        /*    Tab size */
  287.                                 break;
  288.             case    0x11    :    AskPWidth();                    /*    PWidth */
  289.                                 break;
  290.             case    0x25    :    AskPLength();                    /*    PLen */
  291.                                 break;
  292.             default        :    break;
  293.         }
  294.         return;
  295.     }
  296.  
  297.     /***************************************
  298.                     Other Commands
  299.     ***************************************/
  300.  
  301.     if( qu == IEQUALIFIER_NUMERICPAD )
  302.     {
  303.         switch( cd )
  304.         {
  305.             case    0x1e    :    ShowText(( SHORT )( Topline + 1 ));
  306.                                 break;
  307.             case    0x3e    :    ShowText(( SHORT )( Topline - 1 ));
  308.                                 break;
  309.             case    0x1f    :    ShowText(( SHORT )( Topline + 12 ));
  310.                                 break;
  311.             case    0x3f    :    ShowText(( SHORT )( Topline - 12 ));
  312.                                 break;
  313.             case    0x1d    :    ShowText( NumLines );
  314.                                 break;
  315.             case    0x3d    :    ShowText( 0 );
  316.                                 break;
  317.             default        :    break;
  318.         }
  319.     }
  320.  
  321.     if( qu == 0 )
  322.     {
  323.         switch( cd )
  324.         {
  325.             case    0x01    :
  326.             case    0x02    :
  327.             case    0x03    :
  328.             case    0x04    :
  329.             case    0x05    :
  330.             case    0x06    :
  331.             case    0x07    :
  332.             case    0x08    :
  333.             case    0x09    :
  334.             case    0x0a    :    cd    %=    10;
  335.                                 if( CurLay == 2 )
  336.                                     Layout1();
  337.                                 NewSet(( SHORT )cd );
  338.                                 break;
  339.             case    0x44    :    if( CurLay == 1 )
  340.                                     Layout2();
  341.                                 else
  342.                                     Layout1();
  343.                                 break;
  344.             case    0x4c    :    ShowText(( SHORT )( Topline - 1 ));
  345.                                 break;
  346.             case    0x4d    :    ShowText(( SHORT )( Topline + 1 ));
  347.                                 break;
  348.             case    0x5d    :    PrintAll();
  349.                                 break;
  350.             case    0x40    :    NewStyle(( SHORT )(( Sets[ ActSet ].Style + 1 ) % 3 ));
  351.                                 break;
  352.             case    0x33    :    NewCond(( BOOL )( Sets[ ActSet ].Cond ^ TRUE ));
  353.                                 break;
  354.             case    0x28    :    NewLetter(( BOOL )( Sets[ ActSet ].LetterQ ^ TRUE ));
  355.                                 break;
  356.             case    0x20    :    NewLsp(( BOOL )( Sets[ ActSet ].LSpace6 ^ TRUE ));
  357.                                 break;
  358.             case    0x36    :    NewNuming(( SHORT )(( Sets[ ActSet ].Numb + 1 ) % 4 ));
  359.                                 break;
  360.             default        :    break;
  361.         }
  362.         return;
  363.     }
  364. }
  365.  
  366. /************************************************************************
  367. *                                                                                                *
  368. *                                                MenuA                                            *
  369. *                                                                                                *
  370. *                                Na klar, die Menüauswertung ...                        *
  371. *                                                                                                *
  372. *        Parameter    :                                                                        *
  373. *            cd                :    Code in der empfangenen Message                        *
  374. *                                                                                                *
  375. *        Rückgabe        :                                                                        *
  376. *            keine                                                                                *
  377. *                                                                                                *
  378. ************************************************************************/
  379.  
  380. VOID MenuA( USHORT cd )
  381. {
  382.     USHORT                Menu, Item;
  383.     struct MenuItem    *NxMen;
  384.  
  385.     /***/
  386.  
  387.     Menu = MENUNUM( cd );
  388.     Item = ITEMNUM( cd );
  389.     NxMen = ItemAddress( FirstWindow->MenuStrip, cd );
  390.  
  391.     switch( Menu )
  392.     {
  393.         case    0:
  394.             switch( Item )
  395.             {
  396.                 case    0:    if( TwoGadRequest( "Do you really\nwant to quit ?" ))
  397.                                 gRun    =    FALSE;    /*    Quit    */
  398.                             break;
  399.                 case    1:    PrintPageWise();        /* Print */
  400.                             break;
  401.                 case    2:    Load();                    /* Load */
  402.                             break;
  403.                 case    3:    About();                    /* About */
  404.                             break;
  405.                 default:    break;
  406.             }
  407.             break;
  408.  
  409.         case    1:
  410.             switch( Item )
  411.             {
  412.                 case    0:    SaveSettings();        /* Save Sets */
  413.                             break;
  414.                 case    1:    LoadSettings();        /* Load Sets */
  415.                             break;
  416.                 case    2:    AskRMarg();                /* Right Margin */
  417.                             break;
  418.                 case    3:    AskLMarg();                /* Left Margin */
  419.                             break;
  420.                 case    4:    AskTSize();                /*    Tab size */
  421.                             break;
  422.                 case    5:    AskPWidth();            /*    PWidth */
  423.                             break;
  424.                 case    6:    AskPLength();            /*    PLen */
  425.                             break;
  426.                 default:    break;
  427.             }
  428.             break;
  429.  
  430.         default:
  431.             break;
  432.     }
  433.  
  434.     if( NxMen )        MenuA( NxMen->NextSelect );
  435. }
  436.  
  437. /************************************************************************
  438. *                                                                                                *
  439. *        GadgetA                                                                                *
  440. *                                                                                                *
  441. *-----------------------------------------------------------------------*
  442. *                                                                                                *
  443. *        Deals with Gadgets ...                                                            *
  444. *                                                                                                *
  445. *-----------------------------------------------------------------------*
  446. *                                                                                                *
  447. *        Parameters        :                                                                    *
  448. *            gad            :    Pointer to the gadget triggering the message        *
  449. *                                                                                                *
  450. *        Returns            :                                                                    *
  451. *            none                                                                                *
  452. *                                                                                                *
  453. ************************************************************************/
  454.  
  455. VOID        GadgetA( struct Gadget *gad )
  456. {
  457.     switch( gad->GadgetID )
  458.     {
  459.         case    0    :
  460.         case    1    :
  461.         case    2    :
  462.         case    3    :
  463.         case    4    :
  464.         case    5    :
  465.         case    6    :
  466.         case    7    :
  467.         case    8    :
  468.         case    9    :    NewSet( gad->GadgetID );
  469.                         break;
  470.         case    10    :    NewStyle(( SHORT )(( Sets[ ActSet ].Style + 1 ) % 3 ));
  471.                         break;
  472.         case    11    :    NewCond(( BOOL )( Sets[ ActSet ].Cond ^ TRUE ));
  473.                         break;
  474.         case    12    :    NewLetter(( BOOL )( Sets[ ActSet ].LetterQ ^ TRUE ));
  475.                         break;
  476.         case    13    :    NewLsp(( BOOL )( Sets[ ActSet ].LSpace6 ^ TRUE ));
  477.                         break;
  478.         case    14    :    if(( RMarg_info.LongInt >= 0 )&&( RMarg_info.LongInt > Sets[ ActSet ].LMarg ))
  479.                             Sets[ ActSet ].RMarg        =    RMarg_info.LongInt;
  480.                         else
  481.                             RefreshRMarg();
  482.                         break;
  483.         case    15    :    if(( LMarg_info.LongInt >= 0 )&&( LMarg_info.LongInt < Sets[ ActSet ].RMarg ))
  484.                             Sets[ ActSet ].LMarg        =    LMarg_info.LongInt;
  485.                         else
  486.                             RefreshLMarg();
  487.                         break;
  488.         case    16    :    if(( TSize_info.LongInt >= 0 )&&( TSize_info.LongInt <= 12 ))
  489.                         {
  490.                             Sets[ ActSet ].Tabsize    =    TSize_info.LongInt;
  491.                             if( OTSize != Sets[ ActSet ].Tabsize )
  492.                             {
  493.                                 ShowText( Topline );
  494.                                 OTSize    =    Sets[ ActSet ].Tabsize;
  495.                             }
  496.                         }
  497.                         else
  498.                             RefreshTSize();
  499.                         break;
  500.         case    100:    NewNuming(( SHORT )(( Sets[ ActSet ].Numb + 1 ) % 4 ));
  501.                         break;
  502.         case    101:    if( PLength_info.LongInt > 0 )
  503.                             Sets[ ActSet ].PageLen    =    PLength_info.LongInt;
  504.                         else
  505.                             RefreshPLength();
  506.                         break;
  507.         case    102:    if( PWidth_info.LongInt > 0 )
  508.                             Sets[ ActSet ].PageWidth    =    PWidth_info.LongInt;
  509.                         else
  510.                             RefreshPWidth();
  511.                         break;
  512.         case    1000:    Layout2();
  513.                         break;
  514.         case    1001:    Layout1();
  515.                         break;
  516.         case    2000:    PreInit();
  517.                         break;
  518.         case    2001:    PrintPageWise();
  519.                         break;
  520.         case    2002:    PrintAll();
  521.                         break;
  522.         default    :    break;
  523.     }
  524. }
  525.  
  526. /************************************************************************
  527. *                                                                                                *
  528. *        Open_All                                                                                *
  529. *                                                                                                *
  530. *-----------------------------------------------------------------------*
  531. *                                                                                                *
  532. *        This time we open    :    intuition.library                                        *
  533. *                                    graphics.library                                        *
  534. *                                    req.library                                                *
  535. *                                    FirstScreen                                                *
  536. *                                    FirstWindow                                                *
  537. *                                                                                                *
  538. *-----------------------------------------------------------------------*
  539. *                                                                                                *
  540. *        Parameters        :                                                                    *
  541. *            none                                                                                *
  542. *                                                                                                *
  543. *        Returns            :                                                                    *
  544. *            Boolean value : TRUE, if everything is OK; FALSE, if an error    *
  545. *            occured.                                                                            *
  546. *                                                                                                *
  547. ************************************************************************/
  548.  
  549. BOOL    Open_All( VOID )
  550. {
  551.     if(!( FIB = ( struct FileInfoBlock * )AllocMem( sizeof( struct FileInfoBlock ), MEMF_CHIP )))
  552.         return FALSE;
  553.  
  554.     if(!( IntuitionBase = ( struct IntuitionBase * )OpenLibrary( "intuition.library", 0L )))
  555.         return FALSE;
  556.  
  557.     if(!( GfxBase    =    ( struct GfxBase * )OpenLibrary( "graphics.library", 0L )))
  558.         return FALSE;
  559.  
  560.     if(!( ReqBase    =    ( struct ReqBase * )OpenLibrary( "req.library", 0L )))
  561.         return FALSE;
  562.  
  563.     if( Open_Device( "printer.device", 0L, ( CPTR * )&GPrtReq, 0, PRTLEN ) == FALSE )
  564.         return FALSE;
  565.     else
  566.     {
  567.         PrtReq    =    ( struct IOStdReq * )GPrtReq;
  568.         CmdReq    =    ( struct IOPrtCmdReq * )GPrtReq;
  569.     }
  570.  
  571.     if(!( FirstScreen = ( struct Screen * )OpenScreen( &FirstNewScreen )))
  572.         return FALSE;
  573.  
  574.     DoInits( FirstScreen->Height );
  575.  
  576.     SetRGB4( &FirstScreen->ViewPort, 4, 0x00, 0x00, 0x00 );
  577.     SetRGB4( &FirstScreen->ViewPort, 5, 0x00, 0x00, 0x00 );
  578.     SetRGB4( &FirstScreen->ViewPort, 6, 0x00, 0x00, 0x00 );
  579.     SetRGB4( &FirstScreen->ViewPort, 7, 0x00, 0x00, 0x00 );
  580.  
  581.     FirstNewWindow.Screen        =    FirstScreen;
  582.     FirstNewWindow.FirstGadget    =    &Switch1;
  583.  
  584.     if(!( FirstWindow = ( struct Window * )OpenWindow( &FirstNewWindow )))
  585.         return FALSE;
  586.  
  587.     SetMenuStrip( FirstWindow, &Project );
  588.  
  589.     MyProcess                        =    ( struct Process * )FindTask( NULL );
  590.     window_save                        =    MyProcess->pr_WindowPtr;
  591.     MyProcess->pr_WindowPtr        =    ( APTR )FirstWindow;
  592.  
  593.     SetAPen( RP, 1 );
  594.     LoadDefSets();
  595.     DrawImage( RP, &Layout_image, 0, LAYOUT_TOP );
  596.     NewSet( 0 );
  597.  
  598.     getcd( 0, Dir );                /* Current directory path to "Dir" */
  599.  
  600.     SetRGB4( &FirstScreen->ViewPort, 4, 0x0f, 0x0f, 0x0f );
  601.     SetRGB4( &FirstScreen->ViewPort, 5, 0x0c, 0x0c, 0x0d );
  602.     SetRGB4( &FirstScreen->ViewPort, 6, 0x08, 0x08, 0x09 );
  603.     SetRGB4( &FirstScreen->ViewPort, 7, 0x05, 0x05, 0x06 );
  604.  
  605.     return TRUE;
  606. }
  607.  
  608. /************************************************************************
  609. *                                                                                                *
  610. *        Close_All                                                                            *
  611. *                                                                                                *
  612. *-----------------------------------------------------------------------*
  613. *                                                                                                *
  614. *        As ususal : closed everything, that Open_All opened.                    *
  615. *                                                                                                *
  616. *-----------------------------------------------------------------------*
  617. *                                                                                                *
  618. *        Parameters        :                                                                    *
  619. *            none                                                                                *
  620. *                                                                                                *
  621. *        Returns            :                                                                    *
  622. *            none                                                                                *
  623. *                                                                                                *
  624. ************************************************************************/
  625.  
  626. VOID    Close_All( VOID )
  627. {
  628.     if( window_save )        MyProcess->pr_WindowPtr    =    window_save;
  629.     if( FirstWindow )
  630.     {
  631.         ClearMenuStrip( FirstWindow );
  632.         CloseWindow( FirstWindow );
  633.     }
  634.     if( FirstScreen )        CloseScreen( FirstScreen );
  635.     if( GPrtReq )            Close_Device( GPrtReq );
  636.     if( ReqBase )            CloseLibrary( ReqBase );
  637.     if( GfxBase )            CloseLibrary( GfxBase );
  638.     if( IntuitionBase )    CloseLibrary( IntuitionBase );
  639.     if( FIB )                FreeMem( FIB, sizeof( struct FileInfoBlock ));
  640. }
  641.  
  642. /************************************************************************
  643. *                                                                                                *
  644. *        NewSet                                                                                *
  645. *                                                                                                *
  646. *-----------------------------------------------------------------------*
  647. *                                                                                                *
  648. *        Displays a new setting                                                            *
  649. *                                                                                                *
  650. *-----------------------------------------------------------------------*
  651. *                                                                                                *
  652. *        Parameters        :                                                                    *
  653. *            new            :    New setting number                                        *
  654. *                                                                                                *
  655. *        Returns            :                                                                    *
  656. *            none                                                                                *
  657. *                                                                                                *
  658. ************************************************************************/
  659.  
  660. VOID        NewSet( SHORT new )
  661. {
  662.     static struct Image      *Del[] =
  663.     {
  664.         &D0_1_image, &D1_1_image, &D2_1_image, &D3_1_image, &D4_1_image,
  665.         &D5_1_image, &D6_1_image, &D7_1_image, &D8_1_image, &D9_1_image
  666.     };
  667.     static struct Image      *Put[]    =
  668.     {
  669.         &D0_2_image, &D1_2_image, &D2_2_image, &D3_2_image, &D4_2_image,
  670.         &D5_2_image, &D6_2_image, &D7_2_image, &D8_2_image, &D9_2_image
  671.     };
  672.  
  673.     /***/
  674.  
  675.     if( CurLay    ==    1 )
  676.     {
  677.         DrawImage( RP, Del[ ActSet ], ( 10 + ( SHORT )( 21 * ActSet )), NUMTOP );
  678.         DrawImage( RP, Put[ new ], ( SHORT )( 10 + ( 21 * new )), NUMTOP );
  679.         ActSet    =    new;
  680.         NewStyle( Sets[ ActSet ].Style );
  681.         NewCond( Sets[ ActSet ].Cond );
  682.         NewLsp( Sets[ ActSet ].LSpace6 );
  683.         NewLetter( Sets[ ActSet ].LetterQ );
  684.         RefreshTSize();
  685.         RefreshLMarg();
  686.         RefreshRMarg();
  687.     }
  688.     ActSet    =    new;
  689.     if( OTSize != Sets[ ActSet ].Tabsize )
  690.     {
  691.         ShowText( Topline );
  692.         OTSize    =    Sets[ ActSet ].Tabsize;
  693.     }
  694. }
  695.  
  696. /************************************************************************
  697. *                                                                                                *
  698. *        NewStyle                                                                                *
  699. *                                                                                                *
  700. *-----------------------------------------------------------------------*
  701. *                                                                                                *
  702. *        Set a new style                                                                    *
  703. *                                                                                                *
  704. *-----------------------------------------------------------------------*
  705. *                                                                                                *
  706. *        Parameters        :                                                                    *
  707. *            st                :    Number of the new style                                    *
  708. *                                                                                                *
  709. *        Returns            :                                                                    *
  710. *            none                                                                                *
  711. *                                                                                                *
  712. ************************************************************************/
  713.  
  714. VOID        NewStyle( SHORT st )
  715. {
  716.     static struct Image      *Put[]    =
  717.     {
  718.         &Elite_image,
  719.         &Pica_image,
  720.         &Prop_image
  721.     };
  722.  
  723.     /***/
  724.  
  725.     if( CurLay == 1 )
  726.         if(( st >= 0 )&&( st < 3 ))
  727.             DrawImage( RP, Put[ st ], 231, NUMTOP );
  728.     Sets[ ActSet ].Style    =    st;
  729. }
  730.  
  731. /************************************************************************
  732. *                                                                                                *
  733. *        NewCond                                                                                *
  734. *                                                                                                *
  735. *-----------------------------------------------------------------------*
  736. *                                                                                                *
  737. *        Set the Cond-Flag to a new boolen value                                    *
  738. *                                                                                                *
  739. *-----------------------------------------------------------------------*
  740. *                                                                                                *
  741. *        Parameters        :                                                                    *
  742. *            on                :    New value                                                    *
  743. *                                                                                                *
  744. *        Returns            :                                                                    *
  745. *            none                                                                                *
  746. *                                                                                                *
  747. ************************************************************************/
  748.  
  749. VOID        NewCond( BOOL on )
  750. {
  751.     static struct Image      *Put[] =
  752.     {
  753.         &CondOff_image,
  754.         &CondOn_image
  755.     };
  756.  
  757.     /***/
  758.  
  759.     Sets[ ActSet ].Cond    =    on;
  760.     if( CurLay == 1 )
  761.         DrawImage( RP, Put[ on ], 332, NUMTOP );
  762. }
  763.  
  764. /************************************************************************
  765. *                                                                                                *
  766. *        NewLetter                                                                            *
  767. *                                                                                                *
  768. *-----------------------------------------------------------------------*
  769. *                                                                                                *
  770. *        Set LQ to on or off                                                                *
  771. *                                                                                                *
  772. *-----------------------------------------------------------------------*
  773. *                                                                                                *
  774. *        Parameters        :                                                                    *
  775. *            on                :    New boolean value                                            *
  776. *                                                                                                *
  777. *        Returns            :                                                                    *
  778. *            none                                                                                *
  779. *                                                                                                *
  780. ************************************************************************/
  781.  
  782. VOID        NewLetter( BOOL on )
  783. {
  784.     static struct Image      *Put[] =
  785.     {
  786.         &Draft_image,
  787.         &LQ_image
  788.     };
  789.  
  790.     /***/
  791.  
  792.     Sets[ ActSet ].LetterQ    =    on;
  793.     if( CurLay == 1 )
  794.         DrawImage( RP, Put[ on ], 439, NUMTOP );
  795. }
  796.  
  797. /************************************************************************
  798. *                                                                                                *
  799. *        NewLsp                                                                                *
  800. *                                                                                                *
  801. *-----------------------------------------------------------------------*
  802. *                                                                                                *
  803. *        Sets line - space to new boolean value i.e. TRUE means 1/6",        *
  804. *        FALSE means 1/8".                                                                    *
  805. *                                                                                                *
  806. *-----------------------------------------------------------------------*
  807. *                                                                                                *
  808. *        Parameters        :                                                                    *
  809. *            six            :    New boolean value                                            *
  810. *                                                                                                *
  811. *        Returns            :                                                                    *
  812. *            none                                                                                *
  813. *                                                                                                *
  814. ************************************************************************/
  815.  
  816. VOID        NewLsp( BOOL six )
  817. {
  818.     static struct Image      *Put[] =
  819.     {
  820.         &LS8_image,
  821.         &LS6_image
  822.     };
  823.  
  824.     /***/
  825.  
  826.     Sets[ ActSet ].LSpace6    =    six;
  827.     if( CurLay == 1 )
  828.         DrawImage( RP, Put[ six ], 11, SECTOP );
  829. }
  830.  
  831. /************************************************************************
  832. *                                                                                                *
  833. *        NewNuming                                                                            *
  834. *                                                                                                *
  835. *-----------------------------------------------------------------------*
  836. *                                                                                                *
  837. *        Sets a new Numing - type.                                                        *
  838. *                                                                                                *
  839. *-----------------------------------------------------------------------*
  840. *                                                                                                *
  841. *        Parameters        :                                                                    *
  842. *            ty                :    New type                                                        *
  843. *                                                                                                *
  844. ************************************************************************/
  845.  
  846. VOID        NewNuming( SHORT ty )
  847. {
  848.     static struct Image      *Put[]    =
  849.     {
  850.         &Num_No_image,
  851.         &Num_Top_image,
  852.         &Num_Bot_image,
  853.         &Num_Line_image
  854.     };
  855.  
  856.     /***/
  857.  
  858.     Sets[ ActSet ].Numb    =    ty;
  859.     if( CurLay == 2 )
  860.         DrawImage( RP, Put[ty], 151, NUMTOP );
  861. }
  862.  
  863. /************************************************************************
  864. *                                                                                                *
  865. *        Layout1                                                                                *
  866. *                                                                                                *
  867. *-----------------------------------------------------------------------*
  868. *                                                                                                *
  869. *        Draws the first layout - image, and sets the appropriate gadgets    *
  870. *                                                                                                *
  871. *-----------------------------------------------------------------------*
  872. *                                                                                                *
  873. *        Parameters        :                                                                    *
  874. *            none                                                                                *
  875. *                                                                                                *
  876. *        Returns            :                                                                    *
  877. *            none                                                                                *
  878. *                                                                                                *
  879. ************************************************************************/
  880.  
  881. VOID        Layout1( VOID )
  882. {
  883.     RemoveGList( FirstWindow, &Switch2, -1 );
  884.     DrawImage( RP, &Layout_image, 0, LAYOUT_TOP );
  885.     AddGList( FirstWindow, &Switch1, 0, -1, NULL );
  886.     CurLay    =    1;
  887.     DoRefresh();
  888. }
  889.  
  890. /************************************************************************
  891. *                                                                                                *
  892. *        Layout2                                                                                *
  893. *                                                                                                *
  894. *-----------------------------------------------------------------------*
  895. *                                                                                                *
  896. *        Draws the second layout - image, and sets the appropriate gadgets    *
  897. *                                                                                                *
  898. *-----------------------------------------------------------------------*
  899. *                                                                                                *
  900. *        Parameters        :                                                                    *
  901. *            none                                                                                *
  902. *                                                                                                *
  903. *        Returns            :                                                                    *
  904. *            none                                                                                *
  905. *                                                                                                *
  906. ************************************************************************/
  907.  
  908. VOID        Layout2( VOID )
  909. {
  910.     RemoveGList( FirstWindow, &Switch1, -1 );
  911.     DrawImage( RP, &Layout2_image, 0, LAYOUT_TOP );
  912.     AddGList( FirstWindow, &Switch2, 0, -1, NULL );
  913.     CurLay    =    2;
  914.     DoRefresh();
  915. }
  916.  
  917. /************************************************************************
  918. *                                                                                                *
  919. *        RefreshTSize                                                                        *
  920. *                                                                                                *
  921. *-----------------------------------------------------------------------*
  922. *                                                                                                *
  923. *        Puts the current number into the container of the TSize - gadget.    *
  924. *                                                                                                *
  925. *-----------------------------------------------------------------------*
  926. *                                                                                                *
  927. *        Parameters        :                                                                    *
  928. *            none                                                                                *
  929. *                                                                                                *
  930. *        Returns            :                                                                    *
  931. *            none                                                                                *
  932. *                                                                                                *
  933. ************************************************************************/
  934.  
  935. VOID        RefreshTSize( VOID )
  936. {
  937.     if( CurLay == 1 )
  938.     {
  939.         strcpy( TSize_info.Buffer, ltoa( Sets[ ActSet ].Tabsize ));
  940.         TSize_info.LongInt    =    Sets[ ActSet ].Tabsize;
  941.         RefreshGList( &TSize, FirstWindow, NULL, 1 );
  942.     }
  943. }
  944.  
  945. /************************************************************************
  946. *                                                                                                *
  947. *        RefreshRMarg                                                                        *
  948. *                                                                                                *
  949. *-----------------------------------------------------------------------*
  950. *                                                                                                *
  951. *        Refreshes the RMarg - container.                                                *
  952. *                                                                                                *
  953. *-----------------------------------------------------------------------*
  954. *                                                                                                *
  955. *        Parameters        :                                                                    *
  956. *            none                                                                                *
  957. *                                                                                                *
  958. *        Returns            :                                                                    *
  959. *            none                                                                                *
  960. *                                                                                                *
  961. ************************************************************************/
  962.  
  963. VOID        RefreshRMarg( VOID )
  964. {
  965.     if( CurLay == 1 )
  966.     {
  967.         strcpy( RMarg_info.Buffer, ltoa( Sets[ ActSet ].RMarg ));
  968.         RMarg_info.LongInt    =    Sets[ ActSet ].RMarg;
  969.         RefreshGList( &RMarg, FirstWindow, NULL, 1 );
  970.     }
  971. }
  972.  
  973. /************************************************************************
  974. *                                                                                                *
  975. *        RefreshLMarg                                                                        *
  976. *                                                                                                *
  977. *-----------------------------------------------------------------------*
  978. *                                                                                                *
  979. *        Refreshes the LMarg - container.                                                *
  980. *                                                                                                *
  981. *-----------------------------------------------------------------------*
  982. *                                                                                                *
  983. *        Parameters        :                                                                    *
  984. *            none                                                                                *
  985. *                                                                                                *
  986. *        Returns            :                                                                    *
  987. *            none                                                                                *
  988. *                                                                                                *
  989. ************************************************************************/
  990.  
  991. VOID        RefreshLMarg( VOID )
  992. {
  993.     if( CurLay == 1 )
  994.     {
  995.         strcpy( LMarg_info.Buffer, ltoa( Sets[ ActSet ].LMarg ));
  996.         LMarg_info.LongInt    =    Sets[ ActSet ].LMarg;
  997.         RefreshGList( &LMarg, FirstWindow, NULL, 1 );
  998.     }
  999. }
  1000.  
  1001. /************************************************************************
  1002. *                                                                                                *
  1003. *        RefreshPLength                                                                        *
  1004. *                                                                                                *
  1005. *-----------------------------------------------------------------------*
  1006. *                                                                                                *
  1007. *        Refreshes the PLength - container.                                            *
  1008. *                                                                                                *
  1009. *-----------------------------------------------------------------------*
  1010. *                                                                                                *
  1011. *        Parameters        :                                                                    *
  1012. *            none                                                                                *
  1013. *                                                                                                *
  1014. *        Returns            :                                                                    *
  1015. *            none                                                                                *
  1016. *                                                                                                *
  1017. ************************************************************************/
  1018.  
  1019. VOID        RefreshPLength( VOID )
  1020. {
  1021.     if( CurLay == 2 )
  1022.     {
  1023.         strcpy( PLength_info.Buffer, ltoa( Sets[ ActSet ].PageLen ));
  1024.         PLength_info.LongInt    =    Sets[ ActSet ].PageLen;
  1025.         RefreshGList( &PLength, FirstWindow, NULL, 1 );
  1026.     }
  1027. }
  1028.  
  1029. /************************************************************************
  1030. *                                                                                                *
  1031. *        RefreshPWidth                                                                        *
  1032. *                                                                                                *
  1033. *-----------------------------------------------------------------------*
  1034. *                                                                                                *
  1035. *        Refreshes the PWidth - container.                                            *
  1036. *                                                                                                *
  1037. *-----------------------------------------------------------------------*
  1038. *                                                                                                *
  1039. *        Parameters        :                                                                    *
  1040. *            none                                                                                *
  1041. *                                                                                                *
  1042. *        Returns            :                                                                    *
  1043. *            none                                                                                *
  1044. *                                                                                                *
  1045. ************************************************************************/
  1046.  
  1047. VOID        RefreshPWidth( VOID )
  1048. {
  1049.     if( CurLay == 2 )
  1050.     {
  1051.         strcpy( PWidth_info.Buffer, ltoa( Sets[ ActSet ].PageWidth ));
  1052.         PWidth_info.LongInt    =    Sets[ ActSet ].PageWidth;
  1053.         RefreshGList( &PWidth, FirstWindow, NULL, 1 );
  1054.     }
  1055. }
  1056.  
  1057. /************************************************************************
  1058. *                                                                                                *
  1059. *        DoRefresh                                                                            *
  1060. *                                                                                                *
  1061. *-----------------------------------------------------------------------*
  1062. *                                                                                                *
  1063. *        Does a complete refresh                                                            *
  1064. *                                                                                                *
  1065. *-----------------------------------------------------------------------*
  1066. *                                                                                                *
  1067. *        Parameters        :                                                                    *
  1068. *            none                                                                                *
  1069. *                                                                                                *
  1070. *        Returns            :                                                                    *
  1071. *            none                                                                                *
  1072. *                                                                                                *
  1073. ************************************************************************/
  1074.  
  1075. VOID        DoRefresh( VOID )
  1076. {
  1077.     if( CurLay == 1 )
  1078.         NewSet( ActSet );
  1079.     else
  1080.     {
  1081.         NewNuming( Sets[ ActSet ].Numb );
  1082.         RefreshPLength();
  1083.         RefreshPWidth();
  1084.     }
  1085. }
  1086.  
  1087. /************************************************************************
  1088. *                                                                                                *
  1089. *        DoInits                                                                                *
  1090. *                                                                                                *
  1091. *-----------------------------------------------------------------------*
  1092. *                                                                                                *
  1093. *        Initializes all predefined structures for PAL or NTSC                    *
  1094. *                                                                                                *
  1095. *-----------------------------------------------------------------------*
  1096. *                                                                                                *
  1097. *        Parameters        :                                                                    *
  1098. *            SH                :    Screen height                                                *
  1099. *                                                                                                *
  1100. *        Returns            :                                                                    *
  1101. *            none                                                                                *
  1102. *                                                                                                *
  1103. ************************************************************************/
  1104.  
  1105. VOID        DoInits( SHORT SH )
  1106. {
  1107.     LAYOUT_TOP                    =    SH - 56;
  1108.     NUM_LINES                    =    ( LAYOUT_TOP / 8 ) - 2;
  1109.     NUMTOP                        =    LAYOUT_TOP + 5;
  1110.     SECTOP                        =    NUMTOP + 15;
  1111.     STRINGTOP                    =    SECTOP + 3;
  1112.     ACTIONTOP                    =    SECTOP + 16;
  1113.     PT1TOP                        =    NUMTOP + 3;
  1114.     PT2TOP                        =    PT1TOP + 11;
  1115.     SWITCHTOP                    =    NUMTOP + 35;
  1116.  
  1117.     Num9.TopEdge                =    NUMTOP;
  1118.     Num8.TopEdge                =    NUMTOP;
  1119.     Num7.TopEdge                =    NUMTOP;
  1120.     Num6.TopEdge                =    NUMTOP;
  1121.     Num5.TopEdge                =    NUMTOP;
  1122.     Num4.TopEdge                =    NUMTOP;
  1123.     Num3.TopEdge                =    NUMTOP;
  1124.     Num2.TopEdge                =    NUMTOP;
  1125.     Num1.TopEdge                =    NUMTOP;
  1126.     Num0.TopEdge                =    NUMTOP;
  1127.     TSize.TopEdge                =    STRINGTOP;
  1128.     LMarg.TopEdge                =    STRINGTOP;
  1129.     RMarg.TopEdge                =    STRINGTOP;
  1130.     LineSP.TopEdge                =    SECTOP;
  1131.     Letter.TopEdge                =    NUMTOP;
  1132.     Cond.TopEdge                =    NUMTOP;
  1133.     Style.TopEdge                =    NUMTOP;
  1134.     PrAll.TopEdge                =    ACTIONTOP;
  1135.     PPW.TopEdge                    =    ACTIONTOP;
  1136.     Pre.TopEdge                    =    ACTIONTOP;
  1137.     Switch1.TopEdge            =    SWITCHTOP;
  1138.     PWidth.TopEdge                =    PT1TOP;
  1139.     PLength.TopEdge            =    PT2TOP;
  1140.     Numing.TopEdge                =    NUMTOP;
  1141.     Switch2.TopEdge            =    SWITCHTOP;
  1142.  
  1143.     FirstNewWindow.Height    =    SH;
  1144. }
  1145.